package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wmUser.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/v1/material")
@Api(value = "素材管理")
public class WmMaterialController {
    @Autowired
    private WmMaterialService wmMaterialService;

    @ApiOperation("自媒体用户上传素材")
    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(MultipartFile multipartFile) {
        return wmMaterialService.uploadPicture(multipartFile);
    }

    @ApiOperation("素材列表加载")
    @PostMapping("/list")
    public ResponseResult findMaterialList(@RequestBody WmMaterialDto wmMaterialDto) {
        return wmMaterialService.findMaterialList(wmMaterialDto);
    }

    @ApiOperation("图片删除")
    @RequestMapping("/del_picture/{id}")
    public ResponseResult delPictureById(@PathVariable("id") Integer id) {
        return wmMaterialService.delPictureById(id);
    }

    @ApiOperation("取消收藏图片")
    @RequestMapping("/cancel_collect/{id}")
    public ResponseResult collection(@PathVariable("id") Integer id) {
        return wmMaterialService.isCollection(id);
    }

    @ApiOperation("收藏图片")
    @RequestMapping("/collect/{id}")
    public ResponseResult cancelCollection(@PathVariable("id") Integer id) {
        return wmMaterialService.isCollection(id);
    }



}
